<?php
class HotPosts extends CWidget {
	public $posts;
	
	public function init() {
		$optionName = 'hotPosts';
		$option = Options::model()->findOptionByName($optionName);
		$hotPosts = explode(',', $option->optionValue);
		$this->posts = array();
		foreach($hotPosts as $postId) {
			$this->posts[] = Posts::model()->findByPk($postId);
		}
	}
	
	public function run() {
		$this->renderContent();
	}

	public function renderContent($return = false) {
		return $this->render('hotposts', array('posts' => $this->posts), $return);
	}
}